package com.yr.ryjk.user.dao;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.yr.ryjk.user.entity.User;
import com.yr.ryjk.user.vo.UserCensus;

public interface UserMapper {
    int deleteByPrimaryKey(String id);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

	List<User> selectOfPage(int start, int limit, @Param("name")String name,  @Param("phone")String phone);
    
	int selectCount(@Param("name")String name, @Param("phone")String phone);

    @Select("select count(1) from user where phone=#{0}")
    @ResultType(Integer.class)
	int selectCountByPhone(String phone);

    @Select("select * from user where phone=#{0}")
    @ResultMap("BaseResultMap")
	User selectUserByPhone(String phone);

    @Update("update user set password=#{1} where phone=#{0}")
	int updatePasswordByPhone(String phone, String newPassword);

    @Update("update user set last_login_time=#{1} where phone=#{0}")
	void updateLoginTime(String phone, Date date);

    @Update("update user set coin=#{0},coin_md5=#{1} where id=#{2}")
	void updateCoinById(int coin, String coinMd5, String id);

    @Select("select coin from user where phone=#{0}")
    @ResultType(Integer.class)
	int selectCoinByPhone(String phone);
    
	UserCensus getCensusById(String id);
}